import numpy as np
from dask.highlevelgraph import HighLevelGraph
from dask import array as da

# 指定name
name = 'demo'

# 指定dtype
dtype = np.int64

#
layer = {
    (name, 0): np.array(range(10)),  # 第一块的内容
    (name, 1): np.array(range(10,20))  # 第二块的内容
}

# 指定chunks
chunks = ((5,4),)

dask = HighLevelGraph.from_collections(name, layer, dependencies=())

# 创建dask array
darr = da.Array(dask=dask, name=name, chunks=chunks, dtype=dtype)

# print(darr.blocks[0].compute())
print(darr.shape)
print(darr.sum().compute())

import dask.bag as db
b = db.from_sequence([(1,2),(1,3),(3,4,2)])
print(b.compute())
